feat: DH-21476: Middleware plugin infrastructure for widget chaining#2660
feat: DH-21476: Middleware plugin infrastructure for widget chaining#2660vbabich wants to merge 28 commits intodeephaven:mainfrom
Conversation
Add support for middleware plugins that can wrap and enhance widget plugins. Multiple middleware plugins can target the same widget type and are chained in registration order (first registered = outermost wrapper). - Add WidgetMiddlewarePlugin interface with isMiddleware marker - Add WidgetMiddlewareComponentProps and WidgetMiddlewarePanelProps - Add isWidgetMiddlewarePlugin() type guard - Update WidgetLoaderPlugin to collect and chain middleware plugins - Update WidgetView to support middleware chaining - Add unit tests for middleware chaining behavior
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2660 +/- ##
==========================================
+ Coverage 49.54% 50.05% +0.50%
==========================================
Files 774 774
Lines 43898 44074 +176
Branches 11308 11171 -137
==========================================
+ Hits 21749 22060 +311
+ Misses 22103 21996 -107
+ Partials 46 18 -28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mofojed
left a comment
There was a problem hiding this comment.
Looks good overall, just a couple comments/questions
|
Our e2e tests fail in |
| @@ -0,0 +1,110 @@ | |||
| import Log from '@deephaven/log'; | |||
| import { type PluginManifestPluginInfo } from './PluginUtils'; | |||
There was a problem hiding this comment.
Any reason sortPluginsByDependency is in it's own file? Circular reference here between PluginUtils/this, though it's just types... but I'd probably just move this to PluginUtils, or have a utils folder for other utils, or move the type into PluginTypes or something.
There was a problem hiding this comment.
I originally had this function in the utils file, then decided to move it out to a separate file, but didn't check for circular dependencies. Moved it back. Ok if I keep the tests in a separate file?
Middleware Plugin Infrastructure for Widget Chaining
Summary
Adds middleware plugin support so plugins can wrap existing widgets without replacing them, cross-plugin dependency loading via manifest
package/dependenciesfields, and shared plugin-loading utilities in@deephaven/plugin.What Changed
Middleware chaining — New
WidgetMiddlewarePlugintype, identified by its ownPluginType.MIDDLEWARE_PLUGINdiscriminator. Middleware receives aComponentprop and wraps the next layer. Multiple middleware compose in registration order. Applied in bothWidgetLoaderPlugin(dashboard panels) andWidgetView(inline widgets) viacreateChainedComponent/createChainedPanelComponent. The chaining functions automatically filter middleware bysupportedTypesat render time, so middleware only activates for matching widget types.Cross-plugin dependencies — Manifest entries can declare
package(makes the plugin's exports available to other plugins) anddependencies(topological sort so deps load first). Plugins load sequentially so each plugin's exports are available to subsequent plugins via standardimportstatements.Shared loading utilities —
getPluginModuleValue,registerPlugin,processLoadedModule,sortPluginsByDependency, and manifest types moved from@deephaven/app-utilsinto@deephaven/plugin. Both web-client-ui and gplus consume these instead of duplicating the logic. ~80 lines removed from app-utils.Behavior change — duplicate plugin names. When two plugins in the manifest are loaded under the same name, the shared
registerPluginnow skips the duplicate and keeps the first registration (with a warning). Previously the duplicate replaced the existing entry. This applies to plugin-name collisions in the plugin map; widget-type resolution inWidgetLoaderPluginis unaffected (last base plugin still wins for a given widget type).Key Files
packages/plugin/src/PluginTypes.tspackages/plugin/src/PluginUtils.tsxpackages/plugin/src/sortPluginsByDependency.tspackages/plugin/src/WidgetView.tsxpackages/dashboard-core-plugins/src/WidgetLoaderPlugin.tsxpackages/app-utils/src/plugins/PluginUtils.tsxpackages/plugin/docs/middleware-architecture.mdBREAKING CHANGE:
PluginManifestPluginInfo,PluginManifest, andgetPluginModuleValuehave been moved from@deephaven/app-utilsto@deephaven/plugin. Update imports from@deephaven/app-utilsto@deephaven/plugin.